package everydayGrade.t1;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: Siantar
 * @Date: 2023-08-03-22:49
 * @Description: 1.0
 */
public class T0722 {
    //  正则表达式
    public List<String> removeComments(String[] source) {
        //  先转换为字符串
        StringBuilder builder = new StringBuilder();
        for (String s : source) {
            builder.append(s);
            builder.append("\n");
        }

        //  通过正则表达式去匹配，通过\n 换行符分割
        return Arrays.stream(builder.toString()
                        .replaceAll("//.*|/\\*(.|\n)*?\\*/", "")
                        .split("\n"))
                .filter(v -> !v.isEmpty())
                .collect(Collectors.toList());
    }

    @Test
    public void test() {
        String s = " ";
        System.out.println(s.isEmpty());
    }
}
